package algorithm.leetcode;

/**
 * @author bingo
 * @Description    递归求和
 * @Date 2018/6/5
 */
public class Sum {

    public  int sum(int[] arr){
        return sum(arr,0);
    }
    private int sum(int[] arr, int l) {
        if(l==arr.length){
            return 0;
        }
        return  arr[l]+sum(arr,l+1);
    }

    public static void main(String[] args) {
        Sum sum  = new Sum();
        int[] arr = new int[10];
        for(int i=0;i<10;i++){
            arr[i]=i;
        }
        System.out.println(sum.sum(arr));
    }
}
